//
//  MainTabbarCon.swift
//  weiboSwift1.0
//
//  Created by xuNick on 16/4/16.
//  Copyright © 2016年 NN. All rights reserved.
//

import UIKit

class MainTabbarCon: UITabBarController {
    

    
    
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        
        let composeButtonClickClosure = {() -> () in
            
            //弹出composeView
         ComposeView(frame: self.view.frame).show(self)
        
        }
        
        let tab = TabbarView()
        tab.composeButtonClickClosure = composeButtonClickClosure
        
    self.setValue(tab, forKey: "tabBar")
        
        
//        let vc = HMHomeTableViewController()
        
//        vc.title = "首页"
//        vc.tabBarItem.image = UIImage(named: "tabbar_home")
//        vc.tabBarItem.selectedImage = UIImage(named: "tabbar_home_seleted")
//        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.redColor()], forState: .Normal)
//        addChildViewController(vc)
        
        addChild(HMHomeTableViewController(), title: "首页", image: "tabbar_home")
        addChild(HMMessageTableViewController(), title: "消息", image: "tabbar_message_center")
        addChild(HMDiscoverTableViewController(), title: "发现", image: "tabbar_discover")
        addChild(HMProfileTableViewController(), title: "我", image: "tabbar_profile")
        
    }
    
    func addChild(vc: UIViewController,title: String,image: String) -> () {
        
                vc.title = title
                vc.tabBarItem.image = UIImage(named: image)
                vc.tabBarItem.selectedImage = UIImage(named: "\(image)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
                vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: .Normal)
                addChildViewController(UINavigationController(rootViewController: vc))
    }
    
    

}
